package org.thirdHero.db.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 表名 sys_dept
 * @author chensanyong
 * @创建时间： 2019-07-03
 */
public class SysDept implements Serializable {
    /**
     * 主键id
     */
    private Integer id;

    /**
     * 排序
     */
    private Integer num;

    /**
     * 父部门id
     */
    private Integer pid;

    /**
     * 父级ids
     */
    private String pids;

    /**
     * 简称
     */
    private String simplename;

    /**
     * 全称
     */
    private String fullname;

    /**
     * 提示
     */
    private String tips;

    /**
     * 版本（乐观锁保留字段）
     */
    private Integer version;

    /**
     * 
     */
    private Integer level;

    private List<SysDept> children = new ArrayList<>();

    /**
     * 主键id
     * @return id 主键id
     */
    public Integer getId() {
        return id;
    }

    /**
     * 主键id
     * @param id 主键id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * 排序
     * @return num 排序
     */
    public Integer getNum() {
        return num;
    }

    /**
     * 排序
     * @param num 排序
     */
    public void setNum(Integer num) {
        this.num = num;
    }

    /**
     * 父部门id
     * @return pid 父部门id
     */
    public Integer getPid() {
        return pid;
    }

    /**
     * 父部门id
     * @param pid 父部门id
     */
    public void setPid(Integer pid) {
        this.pid = pid;
    }

    /**
     * 父级ids
     * @return pids 父级ids
     */
    public String getPids() {
        return pids;
    }

    /**
     * 父级ids
     * @param pids 父级ids
     */
    public void setPids(String pids) {
        this.pids = pids;
    }

    /**
     * 简称
     * @return simplename 简称
     */
    public String getSimplename() {
        return simplename;
    }

    /**
     * 简称
     * @param simplename 简称
     */
    public void setSimplename(String simplename) {
        this.simplename = simplename;
    }

    /**
     * 全称
     * @return fullname 全称
     */
    public String getFullname() {
        return fullname;
    }

    /**
     * 全称
     * @param fullname 全称
     */
    public void setFullname(String fullname) {
        this.fullname = fullname;
    }

    /**
     * 提示
     * @return tips 提示
     */
    public String getTips() {
        return tips;
    }

    /**
     * 提示
     * @param tips 提示
     */
    public void setTips(String tips) {
        this.tips = tips;
    }

    /**
     * 版本（乐观锁保留字段）
     * @return version 版本（乐观锁保留字段）
     */
    public Integer getVersion() {
        return version;
    }

    /**
     * 版本（乐观锁保留字段）
     * @param version 版本（乐观锁保留字段）
     */
    public void setVersion(Integer version) {
        this.version = version;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", num=").append(num);
        sb.append(", pid=").append(pid);
        sb.append(", pids=").append(pids);
        sb.append(", simplename=").append(simplename);
        sb.append(", fullname=").append(fullname);
        sb.append(", tips=").append(tips);
        sb.append(", version=").append(version);
        sb.append(", level=").append(level);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SysDept other = (SysDept) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getNum() == null ? other.getNum() == null : this.getNum().equals(other.getNum()))
            && (this.getPid() == null ? other.getPid() == null : this.getPid().equals(other.getPid()))
            && (this.getPids() == null ? other.getPids() == null : this.getPids().equals(other.getPids()))
            && (this.getSimplename() == null ? other.getSimplename() == null : this.getSimplename().equals(other.getSimplename()))
            && (this.getFullname() == null ? other.getFullname() == null : this.getFullname().equals(other.getFullname()))
            && (this.getTips() == null ? other.getTips() == null : this.getTips().equals(other.getTips()))
            && (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()))
            && (this.getLevel() == null ? other.getLevel() == null : this.getLevel().equals(other.getLevel()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getNum() == null) ? 0 : getNum().hashCode());
        result = prime * result + ((getPid() == null) ? 0 : getPid().hashCode());
        result = prime * result + ((getPids() == null) ? 0 : getPids().hashCode());
        result = prime * result + ((getSimplename() == null) ? 0 : getSimplename().hashCode());
        result = prime * result + ((getFullname() == null) ? 0 : getFullname().hashCode());
        result = prime * result + ((getTips() == null) ? 0 : getTips().hashCode());
        result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
        result = prime * result + ((getLevel() == null) ? 0 : getLevel().hashCode());
        return result;
    }

    /**
     * sys_dept
     */
    public enum Column {
        id("id", "id", "INTEGER", false),
        num("num", "num", "INTEGER", false),
        pid("pid", "pid", "INTEGER", false),
        pids("pids", "pids", "VARCHAR", false),
        simplename("simplename", "simplename", "VARCHAR", false),
        fullname("fullname", "fullname", "VARCHAR", false),
        tips("tips", "tips", "VARCHAR", false),
        version("version", "version", "INTEGER", false),
        level("level", "level", "INTEGER", true);

        /**
         */
        private static final String BEGINNING_DELIMITER = "`";

        /**
         */
        private static final String ENDING_DELIMITER = "`";

        /**
         */
        private final String column;

        /**
         */
        private final boolean isColumnNameDelimited;

        /**
         */
        private final String javaProperty;

        /**
         */
        private final String jdbcType;

        public String value() {
            return this.column;
        }

        public String getValue() {
            return this.column;
        }

        public String getJavaProperty() {
            return this.javaProperty;
        }

        public String getJdbcType() {
            return this.jdbcType;
        }

        Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
            this.column = column;
            this.javaProperty = javaProperty;
            this.jdbcType = jdbcType;
            this.isColumnNameDelimited = isColumnNameDelimited;
        }

        public String desc() {
            return this.getEscapedColumnName() + " DESC";
        }

        public String asc() {
            return this.getEscapedColumnName() + " ASC";
        }

        public static Column[] excludes(Column ... excludes) {
            ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
            if (excludes != null && excludes.length > 0) {
                columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
            }
            return columns.toArray(new Column[]{});
        }

        public String getEscapedColumnName() {
            if (this.isColumnNameDelimited) {
                return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
            } else {
                return this.column;
            }
        }

        public String getAliasedEscapedColumnName() {
            return this.getEscapedColumnName();
        }
    }

    public List<SysDept> getChildren() {
        return children;
    }

    public void setChildren(List<SysDept> children) {
        this.children = children;
    }
}